
class NewsDetail {
  String id;
  String title;
  int hits;
  String coverUrl;
  DateTime createTime;
  String brief;
  String videoUrl;
  String content;
  NewsContentType contentType;

  NewsDetail({
    this.id,
    this.title,
    this.hits,
    this.coverUrl,
    this.createTime,
    this.brief,
    this.contentType,
    this.content,
    this.videoUrl,
  });

  static NewsDetail fromJson(Map<String, dynamic> json) {
    return NewsDetail(
      id: json['id'].toString(),
      title: json['title'].toString(),
      hits: json['hits'] as int,
      coverUrl: json['coverUrl'].toString(),
      createTime: DateTime.parse(json['createTime']),
      brief: json['brief'].toString(),
      videoUrl: json['videoUrl'].toString(),
      content: json['content'].toString(),
      contentType: NewsContentType.values[json['contentType'] as int],
    );
  }
}

enum NewsContentType { Content, Video }
